package com.wc.alorithm_luogu.P1303;

import java.util.Scanner;

/**
 * @Author congge
 * @Date 2023/4/25 17:01
 * @description https://www.luogu.com.cn/problem/P1303
 * A*B Problem
 */
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();

        System.out.println(multiple(a, b));
    }

    public static String multiple(String a, String b) {
        if (a.length() > b.length()) {
            return multiple(b, a);
        }
        // 存储每一位置的数字
        int[] num = new int[a.length() + b.length()];

        int indexA = a.length() - 1;
        int indexB = b.length() - 1;
        int indexNum = num.length - 1;

        int curMul;
        char[] A = a.toCharArray();
        char[] B = b.toCharArray();

        for (int i = indexA; i >= 0; i--) {
            // 当前位置前进
            int curIndexNum = indexNum;
            for (int j = indexB; j >= 0; j--) {
                curMul = (A[i] - '0') * (B[j] - '0');
                num[curIndexNum] += curMul % 10;
                num[curIndexNum - 1] += curMul / 10;
                curIndexNum--;
            }
            // 表示当前的位数
            indexNum--;
        }

        int carry = 0;
        int curBit = 0;
        // 将数字进位
        for (int i = num.length - 1; i >= 0; i--) {
            curBit = num[i] + carry;
            carry = curBit / 10;
            num[i] = curBit % 10;
        }
        StringBuilder ans = new StringBuilder();

        // 处理前置0问题
        indexNum = 0;
        while (indexNum < num.length && num[indexNum] == 0) {
            indexNum++;
        }
        if (indexNum == num.length) {
            ans.append(0);
        }
        for (int i = indexNum; i < num.length; i++) {
            ans.append(num[i]);
        }

        return ans.toString();
    }
}
